﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ymatou.ServiceCenter.Common
{
    public static class ExceptionExtensions
    {
        public static string ToStringHasInnerExceptions(this AggregateException exception)
        {
            if (exception == null)
                return null;
            StringBuilder sb = new StringBuilder();
            sb.Append(exception.ToString()).Append("{InnerExceptions:");
            foreach (var e in exception.InnerExceptions)
            {
                if (e == null)
                    continue;
                sb.Append("[").Append(e.ToString()).Append("] ");
            }
            sb.Append("}");
            return sb.ToString();
        }
    }
}
